/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package minipaint4Vista;

import MiniPaint4Logica.DatosDeFigura;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.Rectangle;
import java.util.List;
import javax.swing.JComponent;

/**
 *
 * @author Micosil
 */
class Circulo extends JComponent {
    private final int X;
    private final int Y;
    private final int Height;
    private final int Width;
            

    public Circulo(Point puntoUno, Point point, Rectangle visibleRect, List<DatosDeFigura> datos) {
        if (puntoUno.x > point.x){ //Sin esto, salen rectangulos a veces rellenos, otras no.
            int aux = puntoUno.x;
            puntoUno.x = point.x;
            point.x = aux;
        }
        if (puntoUno.y > point.y){
            int aux = puntoUno.y;
            puntoUno.y = point.y;
            point.y = aux;
        }
        datos.add(new DatosDeFigura("Circulo", puntoUno, point));
        X = (int) puntoUno.getX();
        Y = (int) puntoUno.getY();
        Height = (int) (point.getY()-puntoUno.getY());
        Width = (int) (point.getX()-puntoUno.getX()); 
        this.setBounds(visibleRect);
    }
    
    @Override
    public void paint(Graphics g) {
        super.paint(g);
        Graphics2D g2d = (Graphics2D)g;
        g2d.drawOval(X, Y, Width, Height);
    }
    
    
}
